import type { App } from 'vue';
import { createRouter, createWebHistory } from 'vue-router';
import createRouterGuard from './guard'
import { routes } from '@/router/_generated/routes';
import { transformToVueRoutes } from '@/router/_generated/transformer';
import { layouts, views } from '@/router/_generated/imports';

export const router = createRouter({
    history: createWebHistory(),
    routes: transformToVueRoutes(routes, layouts, views)
});


/** Setup Vue Router */
export async function setupRouter(app: App) {
    app.use(router);
    createRouterGuard(router);
    await router.isReady();
}